package com.marketing.controller;

import com.marketing.service.AdvertiseService;
import com.nameless.entity.Advertise;
import com.nameless.vo.AdvertiseVo;
import com.nameless.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author WHZ
 * @date 2023年02月28日 17:09
 */
@RestController
@RequestMapping("/marketing/advertise")
public class AdvertiseController {
    @Autowired
    private AdvertiseService advertiseService;

    /**
     * 分页，模糊查询
     * @param advertiseVo
     * @return
     */
    @PostMapping("/list")
    public Result<List<Advertise>> list(@RequestBody AdvertiseVo advertiseVo){
        return advertiseService.findAll(advertiseVo);
    }

    /**
     * 添加
     * @param advertise
     * @return
     */
    @PostMapping("save")
    public Result save(@RequestBody Advertise advertise){
        return advertiseService.add(advertise);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("delete")
    public Result delete(Integer id) {
        return advertiseService.del(id);
    }

    /**
     * 修改
     * @param advertise
     * @return
     */
    @PutMapping("updateById")
    public Result update(@RequestBody Advertise advertise){
        return advertiseService.put(advertise);
    }
}
